package com.chuisha.controller;

import com.chuisha.AsyncConfiguration;
import com.chuisha.service.TestServiceImpl;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.Executor;


@RestController
@Slf4j
public class MyController {

    @Resource(name = AsyncConfiguration.SYNC_COMMON_EXECUTOR)
    private Executor threadPoolTaskExecutor;
    @Autowired
    private TestServiceImpl testService;

    @GetMapping("/trace")
    public String getTraceId() {
        log.info("getTraceId");
        threadPoolTaskExecutor.execute(() -> {
            log.info("AAABBB");
        });
        testService.async();
        return "tracer.currentSpan().context().traceId()";
    }
}
